package icu.shaoyayu.common.utll.exception;

import lombok.Data;
import lombok.EqualsAndHashCode;

/**
 * @author shaoyayu
 * @date 2021/12/22
 * @apiNote
 */
@EqualsAndHashCode(callSuper = true)
@Data
public class CustomException extends RuntimeException {

    /**
     * 错误代码
     */
    private Integer code;

    /**
     * 错误信息
     */
    private String msg;

    public CustomException(CustomExceptionType customExceptionType){
        this.code = customExceptionType.getCode();
        this.msg = customExceptionType.getDesc();
    }

    /**
     * 自定义异常
     * @param msg 错误信息
     */
    public CustomException(String msg){
        this.msg = msg;
        this.code = 200;
    }
}
